package lab2;

import javax.annotation.processing.Processor;
import java.io.IOException;

public class FillArrayTest {
    public static void main(String[] args) {
        ArrayThread thread[] = new ArrayThread[3];
        ArrayThread.setArr();
        for (int i = 0; i < 3; ++i) {
            thread[i] = new ArrayThread(i);
        }
        for (int i = 0; i < 3; ++i) {
            thread[i].start();
        }
        for(int j=0;j<10000000;j++){
            for(int p=0;p<10000000;p++){
            // 	update the progress bar
                printProgress(thread);
                if(thread[0].isFinished() && thread[1].isFinished()
                        && thread[2].isFinished()){
                    printProgress(thread);
                    return;
                }
            }
        }
    }

    private static void printProgress(ArrayThread[] thread) {
        StringBuilder sb= new StringBuilder();
       sb.append("第" + (thread[0].col / 10 + 1) + "阶段");
        sb.append(thread[0].getProgressStr());
        sb.append(thread[1].getProgressStr());
        sb.append(thread[2].getProgressStr());
        System.out.printf("\r%s", sb);
    }
}
